﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="userManage.aspx.cs" Debug="true" Inherits="Manage_userManage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="Stylesheet" type="text/css" href="css/admin.css" />

    <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
    <style type="text/css">
        .inputfoucs
        {
            font-size: 12px;
            padding: 3px;
            border: 1px solid #f7ca06;
            background: #fffbca;
            color: #cb6a24;
        }
        .inputblur
        {
            font-size: 12px;
            padding: 3px;
            background: #f8f9ff;
            border: 1px solid #c4c9fd;
            color: #6C63A3;
        }
    </style>
    <script type="text/javascript">
        $(function() {
            $("#btn_Submit").click(function() {

                //验证
                if ($("#txt_UserId").val() == "") {
                    $("#txt_UserId").addClass("inputfoucs");
                    $("#txt_UserId").focus();
                    return false;
                } else {
                    $("#txt_UserId").removeClass("inputfoucs");
                }

                if ($("#txt_UserName").val() == "") {
                    $("#txt_UserName").addClass("inputfoucs");
                    $("#txt_UserName").focus();
                    return false;
                } else {
                    $("#txt_UserName").removeClass("inputfoucs");
                }

                if ($("#txt_UserPwd").val() == "") {
                    $("#txt_UserPwd").addClass("inputfoucs");
                    $("#txt_UserPwd").focus();
                    return false;
                } else {
                    $("#txt_UserPwd").removeClass("inputfoucs");
                }

                if ($("#txt_TwoPwd").val() == "") {
                    $("#txt_TwoPwd").addClass("inputfoucs");
                    $("#txt_TwoPwd").focus();
                    return false;
                } else {
                    $("#txt_TwoPwd").removeClass("inputfoucs");
                }

                if ($("#txt_TwoPwd").val() != $("#txt_UserPwd").val()) {
                    alert("您输入的密码与第一次输入的不相同，请重新输入");
                    $("#txt_TwoPwd").val("");
                    $("#txt_TwoPwd").addClass("inputfoucs");
                    $("#txt_TwoPwd").focus();
                    return false;
                } else {
                    $("#txt_TwoPwd").removeClass("inputfoucs");
                }
            })
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
            <tr height="28">
                <td background="images/title_bg1.jpg">
                    当前位置:
                    <asp:SiteMapPath ID="SiteMapPath1" runat="server" SiteMapProvider="ManageSiteMapProvider">
                    </asp:SiteMapPath>
                </td>
            </tr>
            <tr>
                <td bgcolor="#b1ceef" height="1">
                </td>
            </tr>
            <tr height="20">
                <td background="images/shadow_bg.jpg">
                </td>
            </tr>
        </table>
        
        <div style="margin-left:10px;margin-right:10px">
            <table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                <tr height="1">
                    <td>
                    </td>
                </tr>
                <tr height="22">
                    <td style="padding-left: 20px; font-weight: bold; color: #ffffff" align="left" background="images/title_bg2.jpg">
                        用户设置
                    </td>
                </tr>
                <tr bgcolor="#ecf4fc" height="12">
                    <td>
                    </td>
                </tr>
                <tr height="5">
                    <td>
                    </td>
                </tr>
            </table>
            <div>
                选择用户的角色：<asp:DropDownList ID="ddl_Role" runat="server" 
                    DataTextField="roleName" DataValueField="roleId">
                </asp:DropDownList>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="btn_AddUser" runat="server" Text="新增用户" 
                    onclick="btn_AddUser_Click" />
                <asp:Button ID="btn_SelectUser" runat="server" Text="显示用户信息" 
                    onclick="btn_SelectUser_Click" />
            </div>
            
            <table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                <tr height="20">
                    <td>
                    </td>
                </tr>
                <tr height="22">
                    <td style="padding-left: 20px; font-weight: bold; color: #ffffff" align="left" background="images/title_bg2.jpg">
                        <asp:Label ID="lb_SelectOrAdd" runat="server" Text="用户信息"></asp:Label>
                    </td>
                </tr>
                <tr bgcolor="#ecf4fc" height="12">
                    <td>
                    </td>
                </tr>
                <tr height="5">
                    <td>
                    </td>
                </tr>
            </table>
            <div id="addUser" style="display:none;" runat="server">
                <table>
                    <tr>
                        <td>角色</td>
                        <td>
                            <span style="display:block;"><asp:Label ID="lb_RoleId" Text="roleId" runat="server"></asp:Label></span>
                            <asp:Label ID="lb_Role" ForeColor="Red" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>登录帐号</td>
                        <td>
                            <asp:TextBox ID="txt_UserId" runat="server"></asp:TextBox>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>姓名</td>
                        <td>
                            <asp:TextBox ID="txt_UserName" runat="server"></asp:TextBox>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>密码</td>
                        <td>
                            <asp:TextBox ID="txt_UserPwd" runat="server" ></asp:TextBox>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>再次输入</td>
                        <td>
                            <asp:TextBox ID="txt_TwoPwd" runat="server"></asp:TextBox>
                           
                        </td>
                    </tr>
                    <tr>
                        <td>用户状态</td>
                        <td>
                            <asp:RadioButton ID="RadioButton1" runat="server" GroupName="state" Text="无效" Checked="True" />
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:RadioButton ID="RadioButton2" runat="server" GroupName="state" Text="有效" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center">
                            <asp:Button ID="btn_Submit" runat="server" Text="提交" Width="60px" Height="25px" 
                                onclick="btn_Submit_Click" /></td>
                    </tr>
                </table>
            </div>
            
            <div id="userList" runat="server">
                <asp:GridView ID="grd_UserList" runat="server" AutoGenerateColumns="False" 
                    CellPadding="4" ForeColor="#333333" GridLines="None" Width="80%" 
                    AllowPaging="True" ondatabinding="grd_UserList_DataBinding" 
                    onrowdatabound="grd_UserList_RowDataBound" 
                    onselectedindexchanging="grd_UserList_SelectedIndexChanging">
                    <RowStyle BackColor="#EFF3FB" />
                    <Columns>
                        <asp:BoundField DataField="usrId" HeaderText="登录账号" />
                        <asp:BoundField DataField="roleName" HeaderText="角色" />
                        <asp:BoundField DataField="usrName" HeaderText="姓名" />
                        <asp:TemplateField HeaderText="用户状态">
                           
                            <ItemTemplate>
                                <asp:Label ID="lb_UserState" runat="server" Text='<%# ShowState((int)Eval("usrState")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="操作" ShowHeader="False">
                            <ItemTemplate>
                                <%--<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                    CommandName="Select" Text="操作"></asp:LinkButton>--%>
                                <asp:Button ID="btn_UpdateState" runat="server" CommandName="Select" Text='<%# UpdateState((int)Eval("usrState")) %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
